package com.athuahua.spzx.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: huahua
 * @Date: 2024/7/21 0021
 * @Time: 12:27
 * @Description: MP分页插件
 */
@Configuration
public class MybatisPlusConfiguration {
//    @Bean
//    public AutoFillHandler autoFillHandler() {
//        return new AutoFillHandler();
//    }
//

    //配置mybatis-plus插件
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); //分页
        //乐观锁插件
        //interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());  //乐观锁
        //禁用全表删除插件
        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());  //防全局修改和删除
        return interceptor;
    }
}
